﻿using DotNetCore.CAP;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using Ongoal.Quotation.CapExtensions;
using Ongoal.Quotation.Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Ongoal.Quotation.Cap
{
    /// <summary>
    /// 消息发布器
    /// </summary>
    public interface IMessagePublisher : ICapPublisher
    {

        /// <summary>
        /// 操作数据库和分布式事务发布数据专用方法（微服务数据库未分离时调用方法）
        /// </summary>
        /// <param name="ado"></param>
        /// <param name="func"></param>
        Task<bool> ExecuteDBAndPublishWithTranAsync(IAdo ado, Func<Task<bool>> func);

        /// <summary>
        /// 事务类操作数据库和分布式事务发布数据专用方法（微服务数据库未分离时调用方法）
        /// </summary>
        /// <param name="ado"></param>
        /// <param name="func"></param>
        bool ExecuteDBAndPublish(IAdo ado, Func<bool> func);


        /// <summary>
        /// Asynchronous publish an object message.
        /// </summary>
        /// <param name="name">the topic name or exchange router key.</param>
        /// <param name="contentObj">message body content, that will be serialized. (can be null)</param>
        /// <param name="cancellationToken"></param>
        Task PublishWithDefaultCallbackAsync<T>(string name, T? contentObj, CancellationToken cancellationToken = default);

        /// <summary>
        /// Publish an object message.
        /// </summary>
        /// <param name="name">the topic name or exchange router key.</param>
        /// <param name="contentObj">message body content, that will be serialized. (can be null)</param>
        void PublishWithDefaultCallback<T>(string name, T? contentObj);

        /// <summary>
        /// Schedule a message to be published at the feature time.
        /// </summary>
        /// <param name="delayTime">The delay for message to published.</param>
        /// <param name="name">The topic name or exchange router key.</param>
        /// <param name="contentObj">Message body content, that will be serialized. (can be null)</param>
        /// <param name="callbackName">Callback subscriber name.</param>
        Task PublishDelayWithDefaultCallbackAsync<T>(TimeSpan delayTime, string name, T? contentObj, CancellationToken cancellationToken = default);


    }
}
